/*****************************************************************************
 *
 *                      HUSONG PROPRIETARY INFORMATION
 *
 *          The information contained herein is proprietary to HUSONG
 *           and shall not be reproduced or disclosed in whole or in part
 *                    or used for any design or manufacture
 *              without direct written authorization from HUSONG.
 *
 *            Copyright (c) 2015 by HUSONG.  All rights reserved.
 *
 *****************************************************************************/
package me.send.data.service.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import me.send.business.base.Pager;
import me.send.data.service.mapper.AdvertMapper;
import me.send.data.service.pojo.Advert;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author maxmin
 *
 * @date 2015年9月24日 上午11:14:44
 */
@Service
public class AdvertService {
	
	@Autowired
	AdvertMapper advertMapper;
	
	public List<Advert> getAdvertList(Pager page,String cityName,String startTime,String endTime,String keyCode,String cn){
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("page", page);
		param.put("cityName", cityName);
		param.put("cn", cn);
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("keyCode", keyCode);
		return advertMapper.getAdvertList(param);
	}
	
	public int getAdvertCount(String cityName,String startTime,String endTime,String keyCode,String cn){
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("cityName", cityName);
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("cn", cn);
		param.put("keyCode", keyCode);
		return advertMapper.getAdvertCount(param);
	}
	
	public Advert getAdvertById(int advertid){
		return advertMapper.getAdvertById(advertid);
	}
	public int deleteAdvertById(int advertid){
		return advertMapper.deleteAdvertById(advertid);
	}
	
	public int addAdvert(Advert advert){
		return advertMapper.addAdvert(advert);
	}
	
	public int updateAdvertPic(int advertid,String path){
		Map<String,Object> param = new HashMap<String, Object>();
		param.put("advertid", advertid);
		param.put("path", path);
		return advertMapper.updateAdvertPic(param);
	}
	
	public int updateAdvert(Advert advert){
		return advertMapper.updateAdvert(advert);
	}
}
